home *** CD-ROM | disk | FTP | other *** search
/ Aminet 4 / Aminet 4 - November 1994.iso / aminet / comm / term / vltj5867.lha / VLT / rexx / 2.04ScreenMode.vlt next >
Text File  |  1994-03-29  |  7KB  |  271 lines

  1. /** VLTPhoneBook.vlt
  2. *
  3. *   This program brings up the main VLT PhoneBook requester.
  4. *
  5. *   By W.G.J. Langeveld, February 1992.
  6. *
  7. *   This program really wants to be called *from inside* VLT, so assign
  8. *   ~@VLTPhoneBook.vlt to your favorite function key, or select it from
  9. *   VLT's menu.
  10. *
  11. *   Add the libraries if they're not there yet.
  12. *
  13. **/
  14. if show("l", "rexxarplib.library") = 0 then do
  15.    check = addlib('rexxsupport.library', 0, -30, 0)
  16.    check = addlib('rexxarplib.library',  0, -30, 0)
  17. end
  18. /*
  19. *   The following sequence determines both VLT's screen and port name,
  20. *   and also gets the number screen rows and columns.
  21. */
  22. vltport = address()
  23. cols = ScreenCols(vltport)
  24. if cols == -1 then do
  25.    vltscreen = ""
  26.    cols = ScreenCols()
  27.    rows = ScreenRows()
  28. end
  29. else do
  30.    vltscreen = vltport
  31.    rows = ScreenRows(vltscreen)
  32. end
  33.  
  34. if ~OpenPort(VLTSCREENPORT) then exit 0
  35. /*
  36. *   Set up a host. This time, send all messages to VLT.
  37. */
  38. address AREXX "'x = CreateHost(VLTSCREENMODE, VLTSCREENPORT, "vltscreen")'"
  39. /*
  40. *   Wait until it is ready.
  41. */
  42. do i = 1
  43.    if showlist('p', VLTSCREENMODE) ~= 0 then leave
  44.    call delay 30
  45. end
  46.  
  47. call SetReqColor(VLTSCREENMODE, BACKGROUNDPEN, 0)
  48. /*
  49. *   Open the window
  50. */
  51. idcmp = 'CLOSEWINDOW+GADGETUP+MENUPICK'
  52. flags = 'WINDOWCLOSE+WINDOWDRAG+WINDOWDEPTH+ACTIVATE'
  53.  
  54. call OpenWindow(VLTSCREENMODE, cols - 260, rows - 195, 240, 190, idcmp,   ,
  55.                 flags, "2.04 ScreenMode")
  56.  
  57. "extract screenparams"
  58. parse var VLT.screenparams mode width height size auto depth
  59.  
  60. /*
  61.    102400 (ntsc) or 32768 (default) highres
  62.    102404 (ntsc) or 32772 (default) highres laced
  63.    167936  pal
  64.    167940  pal laced
  65. */
  66.  
  67. if (mode = 102400) | (mode = 32768) then do
  68.    mode = 0
  69.    lace = 0
  70. end
  71. else if (mode = 102404) | (mode = 32772) then do
  72.    mode = 0
  73.    lace = 1
  74. end
  75. else if mode = 167936 then do
  76.    mode = 1
  77.    lace = 0
  78. end
  79. else if mode = 167940 then do
  80.    mode = 1
  81.    lace = 1
  82. end
  83. else do
  84.    "message (You seem to have a non-standard*nmode id:" mode "*nYou may not want to continue.)"
  85.    mode = 0
  86.    lace = 1
  87. end
  88.  
  89. /*
  90. *   Add the gadgets
  91. */
  92. call AddGadget(VLTSCREENMODE,  10,  30, 1, "    NTSC    ", "NTSC")
  93. call AddGadget(VLTSCREENMODE, 130,  30, 2, "    PAL     ", "PAL")
  94. call AddGadget(VLTSCREENMODE,  10,  50, 3, " Interlace  ", "LACE")
  95. call AddGadget(VLTSCREENMODE, 130,  50, 4, " Autoscroll ", "AUTO")
  96. call AddGadget(VLTSCREENMODE,  10,  70,10, " Text ", "TEXT") 
  97. call AddGadget(VLTSCREENMODE,  66,  70,11, "Graph.", "GRAP") 
  98. call AddGadget(VLTSCREENMODE, 122,  70,12, " Max. ", "MAX") 
  99. call AddGadget(VLTSCREENMODE, 178,  70,13, " Extr.", "EXTR") 
  100. call AddGadget(VLTSCREENMODE,  70,  90, 5, width     , "%d%1%g", 150, RIDGEBORDER)
  101. call AddGadget(VLTSCREENMODE,  70, 110, 6, height    , "%d%1%g", 150, RIDGEBORDER)
  102. call AddGadget(VLTSCREENMODE,  70, 130, 7, depth     , "%d%1%g", 150, RIDGEBORDER)
  103. call AddGadget(VLTSCREENMODE,  10, 150, 8, "\    Okay    \"             , "OKAY")
  104. call AddGadget(VLTSCREENMODE, 130, 150, 9, "\   Cancel   \"             , "CANCEL")
  105.  
  106. call SetAPen(VLTSCREENMODE, 1)
  107. call SetFont(VLTSCREENMODE, "topaz.font", 8)
  108. call Move(VLTSCREENMODE, 10,  98)
  109. call Text(VLTSCREENMODE, "Width")
  110. call Move(VLTSCREENMODE, 10, 118)
  111. call Text(VLTSCREENMODE, "Height")
  112. call Move(VLTSCREENMODE, 10, 138)
  113. call Text(VLTSCREENMODE, "Depth")
  114.  
  115. if mode = 0 then call SetGadget(VLTSCREENMODE, 1, ON)
  116. if mode = 1 then call SetGadget(VLTSCREENMODE, 2, ON)
  117. if lace = 1 then call SetGadget(VLTSCREENMODE, 3, ON)
  118. if auto = 1 then call SetGadget(VLTSCREENMODE, 4, ON)
  119. call SetGadget(VLTSCREENMODE, 9 + size, ON)
  120.  
  121. quitflag  = 0
  122. finalpass = 0
  123.  
  124. do forever
  125.    if quitflag = 1 then leave
  126.    t = waitpkt(VLTSCREENPORT)
  127.    do forever
  128.       p = getpkt(VLTSCREENPORT)
  129.       if c2d(p) = 0 then leave
  130.  
  131.       cmd = getarg(p)
  132.       if datatype(cmd, 'W') ~= 0 then string = getarg(p, 1)
  133.  
  134.       t = reply(p, 0)
  135. /*
  136. *   See what we got
  137. */
  138.       if finalpass = 0 then do
  139.          if cmd = CLOSEWINDOW then do
  140.             call CloseWindow(hostname)
  141.             quitflag = 1
  142.          end
  143.          else if cmd = "NTSC" then do
  144.             if mode ~= 0 then do
  145.                call SetGadget(VLTSCREENMODE, 1, ON)
  146.                call SetGadget(VLTSCREENMODE, 2, OFF)
  147.                mode = 0
  148.             end
  149.          end
  150.          else if cmd = "PAL" then do
  151.             if mode = 0 then do
  152.                call SetGadget(VLTSCREENMODE, 1, OFF)
  153.                call SetGadget(VLTSCREENMODE, 2, ON)
  154.                mode = 1
  155.             end
  156.          end
  157.          else if cmd = "LACE" then do
  158.             if lace = 0 then do
  159.                call SetGadget(VLTSCREENMODE, 3, ON)
  160.                lace = 1
  161.             end
  162.             else do
  163.                call SetGadget(VLTSCREENMODE, 3, OFF)
  164.                lace = 0
  165.             end
  166.          end
  167.          else if cmd = "AUTO" then do
  168.             if auto = 0 then do
  169.                call SetGadget(VLTSCREENMODE, 4, ON)
  170.                auto = 1
  171.             end
  172.             else do
  173.                call SetGadget(VLTSCREENMODE, 4, OFF)
  174.                auto = 0
  175.             end
  176.          end
  177.          else if cmd = "TEXT" then do
  178.             if size ~= 1 then do
  179.                call SetGadget(VLTSCREENMODE, 9 + size, OFF)
  180.                call SetGadget(VLTSCREENMODE, 10, ON)
  181.                size = 1
  182.             end
  183.          end
  184.          else if cmd = "GRAP" then do
  185.             if size ~= 2 then do
  186.                call SetGadget(VLTSCREENMODE, 9 + size, OFF)
  187.                call SetGadget(VLTSCREENMODE, 11, ON)
  188.                size = 2
  189.             end
  190.          end
  191.          else if cmd = "MAX" then do
  192.             if size ~= 3 then do
  193.                call SetGadget(VLTSCREENMODE, 9 + size, OFF)
  194.                call SetGadget(VLTSCREENMODE, 12, ON)
  195.                size = 3
  196.             end
  197.          end
  198.          else if cmd = "EXTR" then do
  199.             if size ~= 4 then do
  200.                call SetGadget(VLTSCREENMODE, 9 + size, OFF)
  201.                call SetGadget(VLTSCREENMODE, 13, ON)
  202.                size = 4
  203.             end
  204.          end
  205.          else if cmd = "OKAY" then do
  206. /*
  207. *   Send read requests for all gadgets and set up for second pass
  208. */
  209.             call ReadGadget(VLTSCREENMODE, 5)
  210.             call ReadGadget(VLTSCREENMODE, 6)
  211.             call ReadGadget(VLTSCREENMODE, 7)
  212.             finalpass = 1
  213.          end
  214.          else if cmd = CANCEL then do
  215.             call CloseWindow(VLTSCREENMODE)
  216.             quitflag = 1
  217.          end
  218.       end
  219.       else do
  220. /*
  221. *   Second pass. We're reading the gadgets
  222. */
  223.          if datatype(cmd, 'W') ~= 0 then do
  224.             if cmd = 5 then width  = string
  225.             if cmd = 6 then height = string
  226.             if cmd = 7 then do
  227.                depth = string
  228.                call CloseWindow(VLTSCREENMODE)
  229.                quitflag = 1
  230.             end
  231.          end
  232.       end
  233.    end
  234. end
  235.  
  236. /*
  237. *   Write out the modified data
  238. */
  239. if finalpass = 1 then do
  240.    if mode = 0 then do
  241.       if lace = 0 then do
  242.          mode = 102400
  243.       end
  244.       else do
  245.          mode = 102404
  246.       end
  247.    end
  248.    else do
  249.       if lace = 0 then do
  250.          mode = 167936
  251.       end
  252.       else do
  253.          mode = 167940
  254.       end
  255.    end
  256.  
  257.    if depth > 3     then depth  = 3
  258.    if depth < 1     then depth  = 1
  259.    if auto ~= 0     then auto   = 1
  260.    if width < 320   then width  = 320
  261.    if height < 200  then height = 200
  262.    if size > 4      then size   = 4
  263.    if size < 1      then size   = 1
  264.  
  265.    "customscreen mode" mode "autoscroll" auto "width" width "height" height "depth" depth "overscan" size
  266.  
  267. end
  268.  
  269.  
  270. exit
  271.